package com.example.activiti7.controller;

import com.example.activiti7.domain.model.req.QueryHisTaskListReq;
import com.example.activiti7.domain.model.req.QueryTaskListReq;
import com.example.activiti7.domain.model.req.TaskReq;
import com.example.activiti7.domain.model.resp.Page;
import com.example.activiti7.domain.model.resp.Response;
import com.example.activiti7.domain.model.vo.HistoricTaskVO;
import com.example.activiti7.domain.model.vo.TaskVO;
import com.example.activiti7.domain.service.ProcessTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/overflow/task")
@Tag(name = "流程任务服务能力", description = "流程任务接口服务管理")
public class ProcessTaskController {
    private final ProcessTaskService processTaskService;

    public ProcessTaskController(ProcessTaskService processTaskService) {
        this.processTaskService = processTaskService;
    }

    @Operation(summary = "查询待办列表")
    @PostMapping(value = "/queryTodoTasks")
    public Response<Page<TaskVO, QueryTaskListReq>> queryTodoTasks(@RequestBody QueryTaskListReq req) {
        return processTaskService.queryTodoTasks(req);
    }

    @Operation(summary = "查询已办列表")
    @PostMapping(value = "/queryDoneTasks")
    public Response<Page<HistoricTaskVO, QueryTaskListReq>> queryDoneTasks(@RequestBody QueryTaskListReq req) {
        return processTaskService.queryDoneTasks(req);
    }

    @Operation(summary = "查询历史任务列表")
    @PostMapping(value = "/queryHisTasks")
    public Response<Page<HistoricTaskVO, QueryHisTaskListReq>> queryHisTasks(@RequestBody QueryHisTaskListReq req) {
        return processTaskService.queryHisTasks(req);
    }

    @Operation(summary = "批复任务")
    @PostMapping("/completeTask")
    public Response<Boolean> completeTask(@RequestBody TaskReq req) {
        return processTaskService.completeTask(req);
    }

    @Operation(summary = "转办任务")
    @PostMapping("/turnTask")
    public Response<Boolean> turnTask(@RequestBody TaskReq req) {
        return processTaskService.turnTask(req);
    }

    @Operation(summary = "驳回任务")
    @PostMapping("/rejectTask")
    public Response<Boolean> rejectTask(@RequestBody TaskReq req) {
        return processTaskService.rejectTask(req);
    }

    @Operation(summary = "撤回任务")
    @PostMapping("/undoSubmitTask")
    public Response<Boolean> undoSubmitTask(@RequestBody TaskReq req) {
        return processTaskService.undoSubmitTask(req);
    }

}
